package com.fupan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fupan.entity.Book;
import com.fupan.mapper.BookMapper;
import com.fupan.service.BookService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stec
 * @since 2023-02-13 04:28:56
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {

    @Autowired
    BookMapper bookMapper;

    @Override
    public Page<Book> getPageBook(Integer currentPage, Integer pageSize) {
        Page<Book> page = new Page<>(currentPage, pageSize);

        QueryWrapper<Book> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("buycount");
        Page<Book> bookPage = bookMapper.selectPage(page, wrapper);

        return bookPage;
    }
}
